package com.cpi.cornpp.instructionspurchaseforecast.form;

import java.util.ArrayList;
import java.util.Calendar;

import org.apache.struts.action.ActionForm;

import com.cpi.cornpp.instructionspurchaseforecast.view.InstructionPurchaseForecastSearchView;
import com.cs.common.init.SystemParameterCollection;
import com.cs.common.items.PeriodYearItem;

public class InstructionPurchaseForecastSearchForm extends ActionForm {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3175208875340953987L;

	private int orderField;

	private int orderType;
	
	private ArrayList periodFrom;
	
	private InstructionPurchaseForecastSearchView instructionPurchaseForecastSearchView;

	public InstructionPurchaseForecastSearchForm() {
		instructionPurchaseForecastSearchView = new InstructionPurchaseForecastSearchView();
		periodFrom = new ArrayList(0);
		Calendar calendar = Calendar.getInstance();
		int forwardYears = SystemParameterCollection.getInstance().getSystemParameterBean("FORECAST_FORWARD_YEARS").getIntValue();
		int backwardYears = SystemParameterCollection.getInstance().getSystemParameterBean("FORECAST_BACKWARD_YEARS").getIntValue();
		int currentYear = calendar.get(Calendar.YEAR);
		for(int i = currentYear - backwardYears; i <= currentYear + forwardYears; i++){
			PeriodYearItem periodYearItem = new PeriodYearItem();
			periodYearItem.setValue(Integer.toString(i));
			periodYearItem.setLabel(Integer.toString(i));
			periodFrom.add(periodYearItem);
		}
		instructionPurchaseForecastSearchView.setFromYear(String.valueOf(currentYear));
		instructionPurchaseForecastSearchView.setToYear(String.valueOf(currentYear));
	}
	
	public ArrayList getPeriodFrom() {
		return periodFrom;
	}

	public void setPeriodFrom(ArrayList periodFrom) {
		this.periodFrom = periodFrom;
	}

	public int getOrderField() {
		return orderField;
	}

	public void setOrderField(int orderField) {
		this.orderField = orderField;
	}

	public int getOrderType() {
		return orderType;
	}

	public void setOrderType(int orderType) {
		this.orderType = orderType;
	}

	public InstructionPurchaseForecastSearchView getInstructionPurchaseForecastSearchView() {
		return instructionPurchaseForecastSearchView;
	}

	public void setInstructionPurchaseForecastSearchView(
			InstructionPurchaseForecastSearchView instructionPurchaseForecastSearchView) {
		this.instructionPurchaseForecastSearchView = instructionPurchaseForecastSearchView;
	}
	
	
}
